//
// Created by 高森森 on 2022/10/16.
//

#ifndef LEETCODE_SOLUTION_26_H
#define LEETCODE_SOLUTION_26_H
#include<bits/stdc++.h>
using namespace std;

class solution_26 {
public:
    vector<int>n;
    vector<int>sums;
    solution_26(vector<int>& nums) {
       sums.resize(nums.size()+1);
       for(int i=0;i<nums.size();i++){
           sums[i+1]=sums[i]+nums[i];
       }
    }

    int sumRange(int left, int right) {
        int sum=0;
        for(int i=left;i<=right;i++){
            sum+=n[i];
        }
        return sum;
    }
    int sumRange2(int left, int right) {
        return sums[right+1]-sums[left];
    }

};


#endif //LEETCODE_SOLUTION_26_H
